package org.dromara.demo.designPattern.责任链模式.service.impl;

import org.dromara.demo.designPattern.责任链模式.controller.AuthLink;
import org.dromara.demo.designPattern.责任链模式.entity.AuthInfo;
import org.dromara.demo.designPattern.责任链模式.service.AuthService;

import java.text.ParseException;
import java.util.Date;

public class Level3AuthLink extends AuthLink {
    public Level3AuthLink(String levelUserId, String
            levelUserName) {
        super(levelUserId, levelUserName);
    }

    public AuthInfo doAuth(String uId, String orderId, Date authDate) {
        Date date = AuthService.queryAuthInfo(levelUserId, orderId);
        if (null == date) {
            return new AuthInfo("0001", "单号：", orderId, " 状态：待三级审批负责人 ", levelUserName);
        }
        AuthLink next = super.next();
        // 判断是否为最后一个审批人，如果是则返回结果
        if (null == next) {
            return new AuthInfo("0000", "单号：", orderId, " 状态：三级审批完成负责人", " 时间：", f.format(date), " 审批人：",
                    levelUserName);
        }
        return next.doAuth(uId, orderId, authDate);
    }

}
